package com.spsoft.vatoutinv.util.ofd;

import com.spsoft.vatoutinv.enums.GenerateInvoiceEnum;
import com.spsoft.vatoutinv.service.generateinvoice.GenerateInvoiceService;
import com.spsoft.vatoutinv.service.generateinvoice.impl.BaseInvoice;
import com.spsoft.vatoutinv.service.generateinvoice.impl.PassengerTransportationInvoice;
import com.spsoft.vatoutinv.service.generateinvoice.impl.RealEstateLeasInvoice;
import com.spsoft.vatoutinv.service.generateinvoice.impl.RealEstateSalesInvoice;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;

/**
 * @author wangy
 * @date 2023/12/20 13:21
 */
@Data
@Service
@RequiredArgsConstructor
public class OfdInvoiceUtils {

    /**
     * 基础发票类型
     */
    private final BaseInvoice baseInvoice;

    /**
     * 不动产销售发票类型
     */
    private final RealEstateSalesInvoice realEstateSalesInvoice;

    /**
     * 不动产租赁发票类型
     */
    private final RealEstateLeasInvoice realEstateLeasInvoice;

    /**
     * 旅客运输
     */
    private final PassengerTransportationInvoice passengerTransportationInvoice;

    // 发票实现类 map 集合
    private final static Map<String, GenerateInvoiceService> MAP = new HashMap<>(4);

    @PostConstruct
    public void buildMap() {
        MAP.put(GenerateInvoiceEnum.BASE_INVOICE.getCode(), baseInvoice);
        MAP.put(GenerateInvoiceEnum.REAL_ESTATE_SALES_INVOICE.getCode(), realEstateSalesInvoice);
        MAP.put(GenerateInvoiceEnum.REAL_ESTATE_LEAS_INVOICE.getCode(), realEstateLeasInvoice);
        MAP.put(GenerateInvoiceEnum.PASSENGER_TRANSPORTATION_INVOICE.getCode(), passengerTransportationInvoice);
    }

    public static GenerateInvoiceService getGenInvoice(String tdys) {
        return MAP.get(tdys);
    }
}